<?php
    function checkName($alertParts, $personParts) {
        $match = TRUE;
        foreach($alertParts as $value) {
            $alertPart = strval($value);
            $alertPartFound = FALSE;
            if ($match) {
                foreach($personParts as $value) {
                    $personPart = strval($value);
                    if (empty($personPart)) {
						$alertPartFound = TRUE;
					} else if (
                        (strlen($alertPart) === 1 && stripos($personPart, $alertPart) === 0) // is Name Initial
                     || (strlen($alertPart) > 1 && stristr($personPart, $alertPart) !== FALSE) // is Partial Name
                    ) { 
                        $alertPartFound = TRUE;
                        unset($personParts[intval(array_search($personPart, $personParts))]);
                        break;
                    }
                }
            }
            $match = $alertPartFound;
        }
        return $match;
    }
    function check($alertFirstNameParts, $alertLastNameParts, $personFirstNameParts, $personLastNameParts)
    {
        $success = 'pink';
        $alertFullName = implode(' ', $alertFirstNameParts) . ' ' . implode(' ', $alertLastNameParts);
        $personFullName = implode(' ', $personFirstNameParts) . ' ' . implode(' ', $personLastNameParts);
        if (checkName($alertFirstNameParts, $personFirstNameParts) && checkName($alertLastNameParts, $personLastNameParts)) {
            $success = 'green';
        } 
        return $personFullName.' <span style="color: '.$success.'">'.$alertFullName.'</span><br>';
    }
    $personFirstNameParts = array('Wayne', 'Vernon', 'Joseph');
    $personLastNameParts = array('Williams');
    $alertNameCollection = array(
        array(array('Wayne', 'Vernon', 'Joseph')    , array('Williams')),
        array(array('V', 'W')                       , array('Williams')),
        array(array('W', 'V')                       , array('Williams')),
        array(array('W')                            , array('Williams')),
        array(array('V')                            , array('Williams')),
        array(array('Vernon', 'W')                  , array('Williams')),
        array(array('Wayne', 'V')                   , array('Williams')),
        array(array('Wayne', 'Vernon')              , array('Williams')),
        array(array('Wayne')                        , array('Williams')),
        array(array('Vernon')                       , array('Williams')),
        array(array('Wayne')                        , array('Will')),
        array(array('Sep')                          , array('Will')),
        array(array('W')                            , array('W')),
        array(array()                               , array('W')),
        array(array('J', 'V', 'W')                  , array('Williams')),
        array(array('Y')                            , array('Williams')),
        array(array()                               , array('L')),
        array(array('W', 'N')                       , array('Williams')),
        array(array('Wayne', 'W')                   , array('Williams')),
        array(array('W', 'W')                       , array('Williams')),
        array(array('Wayne', 'Verion')              , array('Williams')),
        array(array('Williams')                     , array('Wayne'))
    );
    foreach ($alertNameCollection as $alertNameParts) {
        echo check($alertNameParts[0], $alertNameParts[1], $personFirstNameParts, $personLastNameParts);
    }
?>